#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>

int main()
{
      int m,n,k;
      int status,pid;
      m=fork();
      printf("PID:%d\t",getpid());
      printf("The return value of fork():%d\t\t",m);
      printf("he\n");

      n=fork();

      printf("PID:%d\t",getpid());
      printf("The return value of fork():%d\t\t",n);
      printf("ha\n");

      k=fork();

      printf("PID:%d\t",getpid());
      printf("The return value of fork():%d\t\t",k);
      printf("ho\n");

      
      while(  (pid=(waitpid(-1,&status,0) ) )>0 )
      {
            if(WIFEXITED(status)){
                printf("terminated normally\n");
            }
            else{
                printf("terminated abnormally\n");
            }
      }
      exit(0);
}
